﻿function ClientAddDepartment() {
    Url = Portal.OfficeMan.Department.GetAddUrl().value;
    //window.showModalDialog(Url, null, 'dialogHeight: 600px; dialogWidth: 800px; dialogTop: 10px; dialogLeft: 150px; edge: Raised; center: Yes; help: No; scroll: Yes; status: Yes;');
    window.open(Url, "_self");
    //ClientReading();
}

function ClientSaveAddDepartment() {
    DepartmentName = document.getElementById("txtDepartmentName").value;

    RetValue = Portal.OfficeMan.AddDepartment.ServerSideAddDepartment(DepartmentName).value;
    if(RetValue.indexOf("ERROR")!=-1)
    {
        alert(RetValue);
        return;
    }
    alert(RetValue);
    document.getElementById("txtDepartmentName").value = "";
    document.getElementById("txtDepartmentName").focus();
    //window.close();
    window.open('Default.aspx?WebPartId=Department', '_self');
}

function ClientUpdateDepartment(DepartmentId) {
    Url = Portal.OfficeMan.Department.GetUpdateUrl(DepartmentId).value;
    //window.showModalDialog(Url, null, 'dialogHeight: 600px; dialogWidth: 800px; dialogTop: 10px; dialogLeft: 150px; edge: Raised; center: Yes; help: No; scroll: Yes; status: Yes;');
    window.open(Url, "_self");
    //ClientReading();
}

function ClientDeleteDepartment(DepartmentId)
{
    Msg=Portal.OfficeMan.Department.GetConfirmDeleteMsg().value;
    if(confirm(Msg)==false)return;
    RetValue = Portal.OfficeMan.Department.ServerSideDeleteDepartment(DepartmentId).value;
    if(RetValue.indexOf("ERROR")!=-1)
    {
        alert(RetValue);
        return;
    }
    alert(RetValue);
    ClientReading();
}



//function ShowClientUpdateUrlForm(DepartmentId)
//{
//    Url = Portal.OfficeMan.Department.GetUpdateUrl(DepartmentId).value;
//    if(Url.indexOf("ERROR")!=-1)
//    {
//        alert(Url);
//        return;
//    }
//    window.open(Url, "_self");
//    //window.showModalDialog(Url, null, 'dialogHeight: 600px; dialogWidth: 800px; dialogTop: 10px; dialogLeft: 150px; edge: Raised; center: Yes; help: No; scroll: Yes; status: Yes;'); 
//}


function ClientSaveUpdateDepartment(DepartmentId)
{
    DepartmentName = document.getElementById("txtDepartmentName").value;

    RetValue = Portal.OfficeMan.UpdateDepartment.ServerSideUpdateDepartment(DepartmentId, DepartmentName).value;
    if(RetValue.indexOf("ERROR")!=-1)
    {
        alert(RetValue);
        return;
    }
    alert(RetValue);
    window.open('Default.aspx?WebPartId=Department','_self');
}

function ClientReading() {
   document.getElementById("divProcessing").innerHTML = Portal.OfficeMan.Department.GetProcessingText().value;
   setTimeout("RealClientReading()",10);
}

function RealClientReading() {
    rValue = Portal.OfficeMan.Department.GetDepartment().value;
    document.getElementById("divDepartmentContent").innerHTML = rValue;
    document.getElementById("divProcessing").innerHTML = "";
}
